package com.dreamlin.app;


import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

import javax.net.ssl.HttpsURLConnection;

@RunWith(AndroidJUnit4.class)
public class ExampleTest {

    @Test
    public void httpTest() {

        HttpURLConnection conn;
        try {
            URL url = new URL("https://ae01.alicdn.com/kf/U6de089ce45ff468a8f06c50e19ad7379N.jpg");
            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setConnectTimeout(10000);
            conn.setReadTimeout(10000);
            if (conn.getResponseCode() == HttpsURLConnection.HTTP_OK) {
                int contentLength = conn.getContentLength();
                System.out.println(contentLength);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
